package com.sgb.kjwl.view.widget.pricecheck;

import android.content.Context;
import androidx.recyclerview.widget.LinearLayoutManager;
import android.widget.TextView;

import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.pricecheck.CommonStAttrEntity;
import com.sgb.kjwl.view.ui.adapter.pricecheck.StAttributeViewAdapter;
import com.sgb.kjwl.view.widget.MaxHeightRecyclerView;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;

import java.util.List;

public class StAttributeViewWindows extends BasePopWindow {

    private MaxHeightRecyclerView recyclerView;
    private TextView okView;
    private TextView resetView;

    private StAttributeViewAdapter stAttributeViewAdapter;

    private List<CommonStAttrEntity> attributeViewEntityList;


    public StAttributeViewWindows(Context context) {
        super(context, DIR_DOWN_UP);
    }

    @Override
    protected int popLayout() {
        return R.layout.item_attribute_view;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        recyclerView = holder.getPop().findViewById(R.id.skill_list);
        okView = holder.getPop().findViewById(R.id.ok_view);
        resetView = holder.getPop().findViewById(R.id.reset_view);
        okView.setOnClickListener(v -> {
            dissMiss();
            if (onResultClick != null) {
                onResultClick.result(stAttributeViewAdapter.getAdmixtureAttrData(), stAttributeViewAdapter.getOtherAttrData(), null);
            }
        });
        resetView.setOnClickListener(v -> dismiss());
        stAttributeViewAdapter = new StAttributeViewAdapter(mContext, null);
        stAttributeViewAdapter.setMultiSelect(true);
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        recyclerView.setAdapter(stAttributeViewAdapter);
    }

    public void setData(List<CommonStAttrEntity> stAttrubuteViewEntities, boolean isUpdate) {
        this.attributeViewEntityList = stAttrubuteViewEntities;
        stAttributeViewAdapter.setDatas(stAttrubuteViewEntities);
    }
}
